<extend name="Layout/ins_page" />
<block name="content">
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>



    <legend><span></span></legend>
    <div  id='fm1'>
        <div class="fieldset-body">


            <span>品牌名称</span>
            <input  class="mini-textbox" id='c_name'  />

            <a class="mini-button" onclick="search()" enabled="" id='query-bt'  style="margin-top: 5px">&nbsp;&nbsp;查询&nbsp;&nbsp;</a>
            <a class="mini-button" onclick="exportExcel()" enabled="" id='query-bt2'  style="margin-top: 5px">&nbsp;&nbsp;导出&nbsp;&nbsp;</a>



            <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
                 buttons="#tabsButtons"
            >
                <div title="产品经理-品牌 列表" >

                    <div id="datagrid1" class="mini-datagrid" style="height:430px;width: 100%;"
                         url="/SapSupplier/getpmbybrandname20171101data" idField="id"
                         allowResize="true"
                         allowCellEdit="true" allowCellSelect="true" multiSelect="true"
                         allowCellValid="true" oncellvalidation="" showPager="false"
                    >

                        <div property="columns">

                            <div field="product_manager_name"  headerAlign="center"  >产品经理
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="brand_name"  headerAlign="center"  >品牌
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                        </div>
                    </div>
                </div>
                <!-- <div title="Tab2" iconCls="" >
                    2
                </div> -->
            </div>
        </div>
    </div>


    </body>
    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        grid.setPageSize(5000);
        grid.on("drawcell", function (e) {
            var record = e.record,
                column = e.column,
                field = e.field,
                value = e.value;

            //格式化日期
            if (field == "ctime") {
                if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");

            }


            if (field == "relevant_link"||field == "similar_brand_link"||field == "top_link") {
                e.cellHtml = '<a href="' + value + '"  target="_blank"  >' +value+ '</a>';
            }


            if (field == "b_name") {
                var url="/SapSupplier/brandedit/id/";
                e.cellHtml = '<a href="' + url+record.b_id + '"  target="_blank"  >' +value+ '</a>';
            }


            if (field == "logo") {
                e.cellHtml = '<img src="' + value + '"  style="width:50px" >';
            }

            if (field == "s_price") {
                e.cellHtml = value+"<br>"+record.e_price;
            }

            //if(record.examine_status!=1)
                //e.cellStyle = "background:#f9a8a8";

            if (field == "examine_status") {
                e.cellHtml =value==1?"通过":(value==0?"待审核":'未通过') ;
            }

        });

        function checkName(name) {

            if(name){}
            else{
                alert('名称不能为空');
                return true;
            }
        }

        function search(){
            var c_name = mini.get('c_name').getValue();

            if(checkName(c_name))
            {
                return;
            }

            grid.load({c_name:c_name})
        }

        function exportExcel() {
            var c_name = mini.get('c_name').getValue();

            if(checkName(c_name))
            {
                return;
            }

            var f=document.createElement("form");
            f.action="/SapSupplier/getpmbybrandname20171101excel";
            f.method="post";
            f.innerHTML="<input type='hidden' name='c_name' value='"+c_name+"'/>";
            document.body.appendChild(f);
            f.submit();

        }





    </script>
</block>

